import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: hp
 * Date: 2025-08-06
 * Time: 10:16
 */
public class Test {
    public static int lengthOfLongestSubstring(String s) {
        int len = 0;
        int n = s.length();
        int[] hash = new int[128];
        int left = 0,right = 0;
        while (right < n) {
            int i = s.charAt(right);
            hash[i]++;
            //tmmzuxt
            if (hash[i] > 1) {
                while (hash[s.charAt(left)] != 2) {
                    left++;
                }
                hash[i]--;
                left++;
            }
            right++;
            len = Math.max(len,right-left);
        }
        return len;
    }
    public static void main(String[] args) {
        System.out.println(lengthOfLongestSubstring("tmmzuxt"));
    }
}
